package HuaweiOD;

import java.util.Arrays;
import java.util.Scanner;

public class 部门人力分配 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = Integer.parseInt(in.nextLine());
        int[] requirements = Arrays.stream(in.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        System.out.println(solve(m, requirements));

    }

    public static long solve(int m, int[] requirements) {
        Arrays.sort(requirements);

        int len = requirements.length;
        long min = requirements[0];
        long max = requirements[len - 1] + requirements[len - 2];

        long ans = max;

        while (min <= max) {
            long mid = (max + min) >> 1;
            if (check(requirements, m, mid)){
                ans = mid;
                max = mid - 1;
            }else {
                min = mid + 1;
            }
        }

        return ans;

    }

    public static boolean check(int[] requirements, int m, long limit) {
        int l = 0, r = requirements.length - 1;

        while (l <= r) {
            if (requirements[l] + requirements[r] <= limit) {
                l++;
            }
            m--;
            r--;
        }
        
        return m >= 0;
    }
}
